{include file=header.html}

<script type="text/javascript">
/* 替换参数 */
function replaceParam(key, value)
{
    var params = location.search.substr(1).split('&');
    var found  = false;
    for (var i = 0; i < params.length; i++)
    {
        param = params[i];
        arr   = param.split('=');
        pKey  = arr[0];
        if (pKey == 'page')
        {
            params[i] = 'page=1';
        }
        if (pKey == key)
        {
            params[i] = key + '=' + value;
            found = true;
        }
    }
    if (!found)
    {
        value = transform_char(value);
        params.push(key + '=' + value);
    }
    location.assign(SITE_URL + '/index.php?' + params.join('&'));
}

/* 删除参数 */
function dropParam(key)
{
    var params = location.search.substr(1).split('&');
    for (var i = 0; i < params.length; i++)
    {
        param = params[i];
        arr   = param.split('=');
        pKey  = arr[0];
        if (pKey == 'page')
        {
            params[i] = 'page=1';
        }
        if (pKey == key)
        {
            params.splice(i, 1);
        }
    }
    location.assign(SITE_URL + '/index.php?' + params.join('&'));
}

function search_submit()
{
	var conditions = '';
	var start_price = '';
	var end_price = '';
	if($("#search_submit input[name='keyword']").val())
	{
		conditions = '&keyword='+$("#search_submit input[name='keyword']").val();
	}
	if($("#search_submit input[name='start_price']").val())
	{
		start_price = number_format($("#search_submit input[name='start_price']").val(),0);
	}
	if($("#search_submit input[name='end_price']").val())
	{
		end_price   = number_format($("#search_submit input[name='end_price']").val(),0);
	}
	if(start_price && end_price)
	{
		conditions += '&price_min='+start_price+'&price_max='+end_price;
	}
	location.assign(SITE_URL + '/index.php?app=store&id={$store.store_id}&act=search'+conditions);
}
//<!CDATA[
$(function(){
	
	var order = '{$smarty.get.order}';
	var css = '';
	
	<!--{if $smarty.get.order}-->
	order_arr = order.split(' ');
	switch (order_arr[1]){
		case 'desc' : 
			css = 'down-ico';
		break;
		case 'asc' :
			css = 'up-ico';
		break;
		default : 
			css = 'down-ico';
	}
	$('.shop-filter a#'+order_arr[0]).addClass("select");
	$('.shop-filter a#'+order_arr[0]+' i').attr('class',css);
	<!--{/if}-->
	
	<!--{if $smarty.get.price}-->
	var filter_price = '{$smarty.get.price}';
	filter_price = filter_price.split('-');
	$('input[name="start_price"]').val(number_format(filter_price[0],0));
	$('input[name="end_price"]').val(number_format(filter_price[1],0));
	<!--{/if}-->
	
	$(".shop-filter a").click(function(){
		if(this.id==''){
			dropParam('order');// default order
			return false;
		}
		else
		{
			dd = " desc";
			if(order != '') {
				order_arr = order.split(' ');
				if(order_arr[0]==this.id && order_arr[1]=="desc")
					dd = " asc";
				else dd = " desc";
			}
			replaceParam('order', this.id+dd);
			return false;
		}
	});
});
//]]>
</script>
<div id="page">
<div class="w-full col-1" area="top_ad_area" widget_type="area" data-position="banner">
    <!--{widgets page=search area=top_ad_area}-->
</div>
<div id="content">
    <div id="left">
        <div class="" area="store_left" widget_type="area" data-position="left">
            <!--{widgets page=search area=store_left}-->
        </div>
    </div>
    <div id="right">
    	<div class="" area="store_right" widget_type="area" data-position="right">
            <!--{widgets page=search area=store_right}-->
        </div>
        <div class="module_special">
            <!--<h2 class="common_title veins2">
                <div class="ornament1"></div>
                <div class="ornament2"></div>
                <span class="ico1"><span class="ico2">{$search_name|escape}</span></span>
            </h2>-->
            <div class="store-search clearfix">
            	<div class="result">
                            {$lang.search_num}<span> {if $search_count}{$search_count} {else}0{/if} </span>{$lang.qualifying_goods}
                 </div>
                 <div class="search-form">
                      <form action="index.php" id="search_submit" >
                            <label for="keyword">{$lang.keywords}：</label>
                            <input type="text" name="keyword" value="{$smarty.get.keyword}" class="keyword">&nbsp;&nbsp;
                            <label for="price">{$lang.price}：</label>
                            <input type="text" id="price1" name="start_price" value="{$smarty.get.price_min}" class="price" value=""> {$lang.dao}
                            <input type="text" id="price2" name="end_price" value="{$smarty.get.price_max}" class="price" value="">
                            <button type="button" class="button" onclick="search_submit()">{$lang.search}</button>
                        </form>
                 </div>
            </div>    
            <div class="shop-filter clearfix">
                        <span>{$lang.sort_order}：</span>
                        <a href="javascript:;" alt="{$lang.by_new_sort}" title="{$lang.by_new_sort}" {if $smarty.get.order eq ''}class="select"{/if} id="add_time">{$lang.new_goods}<i class="down-ico"></i></a>
                        <a href="javascript:;" alt="{$lang.by_sales_sort}" title="{$lang.by_sales_sort}" id="sales">{$lang.sales}<i class="down-ico"></i></a>
                        <a href="javascript:;" alt="{$lang.by_pop_sort}" title="{$lang.by_pop_sort}" id="views">{$lang.popularity}<i class="down-ico"></i></a>
                        <a href="javascript:;" alt="{$lang.by_price_sort}" title="{$lang.by_price_sort}" id="price">{$lang.price}<i class="up-ico"></i></a>
                        <a href="javascript:;" alt="{$lang.by_collect_sort}" title="{$lang.by_collect_sort}" id="collects">{$lang.collect}<i class="down-ico"></i></a>
                </div>
            <div class="wrap">
                <div class="wrap_child">
                    <!--{if $searched_goods}-->
                    <div class="major">
                        <ul class="list">
                            <!--{foreach from=$searched_goods item=sgoods}-->
                            <li>
                                <div class="pic"><a href="{url app=goods&id=$sgoods.goods_id}" target="_blank"><img src="{$sgoods.default_image}" width="180" height="180" /></a></div>
                                <h3><a href="{url app=goods&id=$sgoods.goods_id}" target="_blank">{$sgoods.goods_name|escape}</a></h3>
                                <p class="clearfix"><span class="price">{$sgoods.price|price}</span>{if $sgoods.market_price > 0}<del>{$sgoods.market_price|price}</del>{/if}</p>
                                <p class="clearfix"><span class="sale">{$lang.sold_out}：<em>{$sgoods.sales}</em> {$lang.goods_unit}</span><span class="comment">{$lang.comment}(<i>{$sgoods.comments}</i>)</span></p>
                            </li>
                            <!--{/foreach}-->
                        </ul>
                    </div>
                    <div style="margin-right:15px;">
                    {include file=page.bottom.html}
                    </div>
                    <!--{else}-->
                    <div class="nothing"><p>{$lang.no_records}</p></div>
                    <!--{/if}-->
                </div>
            </div>
        </div>
    </div>
    
    <div class="clear"></div>
</div>
</div>
{include file=footer.html}